package com.day08_Set_test;

/**
 * @ClassName: Student
 * @Author: 豆豆在睡觉
 * @Create 2024/3/3-22:09
 * @Version 1.0
 */
 public class Student implements Comparable<Student> {
    private String name;
    private int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public int comparaTo(Student s) {
        int age = this.age - s.age;
        return age; // 0 只有1个， 1正序， -1倒序
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {

        this.age = age;
    }

    @Override
    public int compareTo(Student o) {
        return this.age - o.age == 0 ? this.name.compareTo(o.name) : this.age - o.age;
    }

}
